package m.framework.web;
import m.framework.exception.SystemException;
import m.framework.utils.StringUtil;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 构造sessionId和解析sessionId
 * @author ming
 * @date 2014年2月20日上午10:21:24
 */
public class SessionIdCreator {
	private static Logger log = LoggerFactory.getLogger(SessionIdCreator.class);
	
	public String toSessionId(String  userCode){
		return "xxx-"+userCode;
	}
	
	public String toUserCode(String seesionId) throws Exception{
		if(StringUtil.isEmpty(seesionId)){
			return null;
		}
		if(!seesionId.startsWith("xxx-")){
			throw new SystemException("非法的用户标识:"+seesionId);
		}
		return seesionId.substring(4);
	}
}




